﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AgileDashboard.controls
{
    using System.Reflection;

    using log4net;

    public partial class BuildBox : System.Web.UI.UserControl
    {
        public string BuildFeedUrl { get; set; }

        public string Title { get; set; }

        private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public BuildBox()
        {

        }

        public BuildBox(NameValueCollection collection)
        {
            this.BuildFeedUrl = collection["BuildFeedUrl"];
            this.Title = collection["Title"];
        }

        protected override void Render(HtmlTextWriter writer)
        {
            try
            {
                Xml1.DocumentUrl = BuildFeedUrl;
            }
            catch (Exception e)
            {
                if (Log.IsErrorEnabled)
                {
                    Log.Error(string.Format("Error while loading build box control for feedurl {0}", BuildFeedUrl), e);
                }
                errorMsg.Visible = true;
            }

            base.Render(writer);
        }
    }
}